package cn.layfolk.seckill.mq.listener;

import cn.layfolk.daimao.consts.MQConstans;
import cn.layfolk.seckill.web.controller.TOrderInfoController;
import org.apache.rocketmq.spring.annotation.MessageModel;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;



@RocketMQMessageListener(
        topic = MQConstans.SECKILL_ORDER_TOPIC,
        consumerGroup = MQConstans.CLEAR_STOCK_OVER_MAP_GROUP,
        messageModel = MessageModel.BROADCASTING, //使用广播模式 消费消息  可以不需要组
        selectorExpression = MQConstans.CLEAR_STOCK_OVER_MAP_TAG
)
@Component
public class ClearStockOverMapMQListener implements RocketMQListener<Long> {

    private final Logger log = LoggerFactory.getLogger("CLEAR_STOCK_OVER_MAP_MQ_LISTENER");

    @Override
    public void onMessage(Long seckillId) {
        log.info("收到清除本地售完标记消息：{}", seckillId);
        // 清除本地售完标记
        TOrderInfoController.STOCK_OVER_FLAG.put(seckillId, false);

    }
}
